﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Text.RegularExpressions;

namespace RNT.Common.Utils
{
    /// <summary>
    /// 正则表达式验证，无法继承该类。
    /// </summary>
    public sealed class RegexMatch
    {
        /// <summary>
        /// 验证[0-9]纯数字
        /// </summary>
        public static Regex REGNUM0_9 = new Regex(@"^[0-9]\d*$");

        /// <summary>
        ///  验证整数
        /// </summary>
        public static Regex REGNUM = new Regex(@"^-?[1-9]\d*$");

        /// <summary>
        /// 验证浮点数 
        /// </summary>
        public static Regex REGDOUBLE = new Regex(@"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$");

        /// <summary>
        /// 验证IP地址
        /// </summary>
        public static Regex REGIPADDRESS = new Regex(@"(((2[0-4]\\d)|(25[0-5]))|(1\\d{2})|([1-9]\\d)|(\\d))[.](((2[0-4]\\d)|(25[0-5]))|(1\\d{2})|([1-9]\\d)|(\\d))[.](((2[0-4]\\d)|(25[0-5]))|(1\\d{2})|([1-9]\\d)|(\\d))[.](((2[0-4]\\d)|(25[0-5]))|(1\\d{2})|([1-9]\\d)|(\\d))");
        //(验证不严格)
        //new Regex(@"((2[0-4][0-5]|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)");

        /// <summary>
        /// 验证国内电话号码
        /// </summary>
        public static Regex REGPHONE = new Regex(@"\d{4}-\d{7}|\d{3}-\d{8}");

        /// <summary>
        /// 验证帐号是否合法(字母开头，允许5-16字节，允许字母数字下划线)
        /// </summary>
        public static Regex REGUSERACCOUNT = new Regex(@"^[a-zA-Z][a-zA-Z0-9_]{4,15}$");

        /// <summary>
        /// 验证Email地址
        /// </summary>
        public static Regex REGEMAIL = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");

        /// <summary>
        /// 验证日期字符
        /// </summary>
        public static Regex REGDATE = new Regex(@"\d{4}[年|\-|\.]\d{1,2}[月|\-|\.]\d{1,2}日?");

        /// <summary>
        /// 验证中文字符
        /// </summary>
        public static Regex REGCHINESECHARTER = new Regex(@"[\u4e00-\u9fa5]");

    }
}
